import pika

from setting import HOST, PORT, USERNAME, PASSWORD


def get_connection():
    # 建立socket连接
    credentials = pika.PlainCredentials(USERNAME, PASSWORD)
    connection = pika.BlockingConnection(pika.ConnectionParameters(
        host=HOST, port=PORT, virtual_host='/', credentials=credentials
    ))
    return connection
